﻿<cfsilent>
	<cfscript>
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		
		termId = event.getArg("TermID");
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		changeType = event.getArg("T");
		
		studentType = event.getArg("ST");
		
		currentTab = event.getArg("TabID", "labDepartment");
		
		passArgs = structNew();
		structInsert( passArgs, "TID", termId );
		structInsert( passArgs, "T", changeType );
		
		if ( len(studentType) ) {
			structInsert( passArgs, "ST", studentType );
		}
		
		sql = "SELECT a.sct_name
				FROM t_stuchange_type a 
				WHERE a.sct_code = :changeType ";
				
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="changeType", value=changeType, cfsqltype = "cf_sql_char");

		rs_operObj = queryObj.execute( sql=sql ).getResult();
		
		event.setArg("pageTitle", "学生学籍管理 - 学籍异动 - " & rs_operObj.sct_name & "向导");
		
		


		/* 目标班级信息 */
		instituteId = event.getArg("DEP");
		subjectId = event.getArg("SBJ");
		grade = event.getArg("GRD", year(now()) - 1);
		
		/* 学院列表 */
	
		sql = "SELECT 
					b.institute_id, 
					b.institute_name, 
					b.institute_english 
				FROM t_class a 
					 INNER JOIN t_subject ON t_subject.sbj_id = a.sbj_id 
					 INNER JOIN t_institute b ON b.institute_id = t_subject.institute_id 
				GROUP BY 
					b.institute_id, 
					b.institute_name, 
					b.institute_english 
				ORDER BY b.institute_name";
				
		queryObj = new Query( datasource=application.dnsSlave );
		
		rs_ins = queryObj.execute( sql=sql ).getResult();
		
		if ( len(instituteId) ) {
			
			currentTab = event.getArg("TabID", "labSubject");
			
			/* 根据学院 读取招生年级 */
		
			sql = "SELECT 
					distinct a.grade
					FROM t_class a  
						INNER JOIN t_subject ON t_subject.sbj_id = a.sbj_id 
						INNER JOIN t_institute b ON b.institute_id = t_subject.institute_id 
					WHERE
						b.institute_id = :instituteId 
					ORDER BY a.grade DESC ";
			
			queryObj = new Query( datasource=application.dnsSlave,maxRows = 5);
			queryObj.addParam( name="instituteId", value=instituteId, cfsqltype = "cf_sql_varchar");
	
			rs_grade = queryObj.execute( sql=sql ).getResult();

			/* 根据学院和年级 读取专业开设信息 */
			
			sql = "SELECT 
						b.sbj_id, 
						b.sbj_name, 
						b.term_start, 
						b.level_code, 
						c.learning_branch 
					FROM t_class a 
						 INNER JOIN t_subject b ON b.sbj_id = a.sbj_id  
						 INNER JOIN t_learning_branch c ON c.b_id = b.b_id 
					WHERE 
						b.institute_id = :instituteId 
						AND 
						a.grade = :grade 
					GROUP BY 
						b.sbj_id, 
						b.sbj_name, 
						b.term_start, 
						b.level_code, 
						c.learning_branch 
					ORDER BY b.sbj_name";
					
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="instituteId", value=instituteId, cfsqltype = "cf_sql_varchar");
			queryObj.addParam( name="grade", value=grade, cfsqltype = "cf_sql_char");
	
			rs_subject = queryObj.execute( sql=sql ).getResult();
		}
		
		if ( len(subjectId) ) {
			
			currentTab = event.getArg("TabID", "labFormClass");
			
			/* 根据专业 读取招生年级 */
			
			sql = "SELECT 
					distinct a.grade
					FROM t_class a  
					WHERE
						a.sbj_id = :subjectId 
					ORDER BY a.grade DESC ";
			
			queryObj = new Query( datasource=application.dnsSlave,maxRows = 5);
			queryObj.addParam( name="subjectId", value=subjectId, cfsqltype = "cf_sql_varchar");
	
			rs_gradeSBJ = queryObj.execute( sql=sql ).getResult();
			
			/* 根据专业和年级 读取班级信息 */
			
			sql = "SELECT 
						a.cls_id, a.cls_name, 
						a.cls_size, a.cls_scale, 
						b.campus_name
						FROM t_class a 
						INNER JOIN t_campus b ON b.campus_id = a.campus_id 
					WHERE 
						a.sbj_id = :subjectId 
						AND 
						a.grade = :grade 
					ORDER BY a.cls_name";
					
			queryObj = new Query( datasource=application.dnsSlave);
			queryObj.addParam( name="subjectId", value=subjectId, cfsqltype = "cf_sql_varchar");
			queryObj.addParam( name="grade", value=grade, cfsqltype = "cf_sql_char");
	
			rs_class = queryObj.execute( sql=sql ).getResult();
		} 
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('studentStatusChange')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">学籍异动</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>学籍异动向导 <cfoutput>#rs_operObj.sct_name#</cfoutput> 
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="findStudent">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labDepartment">class="active"</cfif> id="labDepartment" tabTarget="Department">选择转入学院</span>
						<cfif len(instituteId)>
							<span <cfif currentTab eq "labSubject">class="active"</cfif> id="labSubject" tabTarget="Subject">选择转入专业</span>
						</cfif>
						<cfif len(subjectId)>
							<span <cfif currentTab eq "labFormClass">class="active"</cfif> id="labFormClass" tabTarget="FormClass">选择转入班级</span>
						</cfif>
						<span <cfif currentTab eq "labImport">class="active"</cfif> id="labImport" tabTarget="Import">批量处理</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
					
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
								
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					// -->
					//]]>
				</script>
				
				<div id="Import" class="tabContent" style="display: block;">
					
					<div class="noticeBlock">
						<h3>导入批量专升本数据</h3>
						<p><span class="img icon16x16 message"></span>请严格按照如下的数据模板在电子表格文件中录入专升本数据. 点击<a href="<cfoutput>#BuildURL("importStudentCreateTemplate")#</cfoutput>">下载专升本录入模板</a>, 在录入信息时请勿更改第一行表头内容.</p>
						<hr>
						<table>
							<tbody><tr>								
								<td>学号</td><td>姓名</td><td>性别</td><td>身份证</td><td>民族</td><td>专科学校</td><td>转入班级</td>
								<td>转入专业</td>
								<td>转入学院</td>
							</tr>
							<tr>
								<td>自行编定</td><td>学生姓名</td><td>男/女</td><td>18位高考身份证号</td><td>[民族]</td><td>学校名称</td><td>行政班全称</td>
								<td>专业名称</td>
								<td>学院名称</td>
							</tr>
						</tbody></table>
						<br>
						<p><span class="img icon16x16 link"></span>选填信息</p>
						<table>
							<tbody><tr>
								<td>曾用名</td><td>出生日期</td><td>家庭地址</td><td>邮编</td><td>审批文号</td>
							</tr>
							<tr>
								<td>姓名</td><td>YYYYMMDD</td><td>家庭通讯地址</td><td>邮政编码</td><td>审批文号</td>
							</tr>
						</tbody></table>
						<hr>
					</div>
					
					<form target="output" onsubmit="javascript:return processVerfiyForm('formImport');" id="formImport" class="formWrapper" method="post" enctype="multipart/form-data" action="<cfoutput>#BuildURL("importStudentCreateDo", { TermID = termId, ChangeTypeCode = changeType })#</cfoutput>">
						
						<div class="label">
							<span class="req">*</span><b>导入数据文件</b>
							<input name="upload" id="upload" type="file" verification="required">
						</div>
						
						<div class="lable"><input id="importTrigger" class="button" type="submit" value="导入专升本数据"></div>
					</form>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$(document).ready(function() {
							$("#importTrigger").click(function(){
								$("#output").attr("src","about:blank").removeClass("hidden_elem");
							});
						});
						// -->
						//]]>
					</script>
					
					
					<iframe name="output" id="output" class="UIframeBox hidden_elem" src="about:blank" frameborder="0"></iframe>
					
				</div>
				
				<div id="Department" class="tabContent">
					
					<div class="noticeBlock">
						<h3>二级院(系)</h3>
						<hr/>
					</div>
				
					<div class="clearfix">
						<div class="UICardTable">
                            <cfloop query="rs_ins" >
								<cfset structInsert(passArgs, "DEP", rs_ins.institute_id, true) />
								<dl <cfif len(instituteId) and instituteId neq rs_ins.institute_id>class="disabled"</cfif>>
									<dt>
										<a href="<cfoutput>#buildURL('statusChangeWizardCreate', passArgs)#</cfoutput>">
											<b class="school"><!--imgholder--></b>
											<dd>
												<h3><cfoutput>#rs_ins.institute_name#</cfoutput></h3>
												<p><cfoutput>#rs_ins.institute_english#</cfoutput></p>
											</dd>
										</a>
									</dt>
								</dl>
							</cfloop>
							<!--- 将部门代码回滚为默认值 --->
							<cfif len(instituteId)>
								<cfset structInsert(passArgs, "DEP", instituteId, true) />
							</cfif>
						</div>
					</div>
					
				</div>
				
				<cfif len(instituteId)>
				
					<div id="Subject" class="tabContent">
					
						<div class="noticeBlock">
							<div class="operation">
                                <cfloop query="rs_grade" >
									<cfset structInsert(passArgs, "GRD", rs_grade.grade, true) />
									<a class="uiButton <cfif rs_grade.grade eq grade>uiButtonSpecial</cfif>" href="<cfoutput>#buildURL('statusChangeWizardCreate', passArgs)#</cfoutput>"><span class="uiButtonText"><cfoutput>#rs_grade.grade#</cfoutput> 级</span></a>
								</cfloop>
								<!--- 将年级回滚为默认值 --->
								<cfset structInsert(passArgs, "GRD", grade, true) />
							</div>
							<h3>选择修读专业和年级</h3>
							<hr/>
						</div>
					
						<cfif rs_subject.recordCount>
								
								<div class="clearfix">
									<div class="UICardTable">
                                        <cfloop query="rs_subject" >
											<cfset structInsert(passArgs, "SBJ", rs_subject.sbj_id, true) />
											<dl <cfif len(subjectId) and subjectId neq rs_subject.sbj_id>class="disabled"</cfif>>
												<dt>
													<a href="<cfoutput>#buildURL('statusChangeWizardCreate', passArgs)#</cfoutput>">
														<em class="subject"><!--imgholder--></em>
														<dd>
															<h3><cfoutput>#rs_subject.sbj_name#</cfoutput></h3>
															<div><cfoutput>#dictAdvice.getTermEnrol(rs_subject.term_start)#-#dictAdvice.getStudentLevel(rs_subject.level_code)#(#rs_subject.learning_branch#)</cfoutput></div>
														</dd>
													</a>
												</dt>
											</dl>
										</cfloop>
										<!--- 将专业回滚为默认值 --->
										<cfset structInsert(passArgs, "SBJ", subjectId, true) />
									</div>
								</div>
								
							<cfelse>
								
								<div class="systemNotice">
									<p>该学院在指定年级没有招生专业</p>
								</div>
								
						</cfif>
					
					</div>
				
				</cfif>
				
				<cfif len(subjectId)>
					
					<div id="FormClass" class="tabContent">
						
						<div class="noticeBlock">
							<div class="operation">
                                <cfloop query="rs_gradeSBJ" >
									<cfset structInsert(passArgs, "GRD", rs_gradeSBJ.grade, true) />
									<a class="uiButton <cfif rs_gradeSBJ.grade eq grade>uiButtonSpecial</cfif>" href="<cfoutput>#buildURL('statusChangeWizardCreate', passArgs)#</cfoutput>"><span class="uiButtonText"><cfoutput>#rs_gradeSBJ.grade#</cfoutput> 级</span></a>
								</cfloop>
								<!--- 将年级回滚为默认值 --->
								<cfset structInsert(passArgs, "GRD", grade, true) />
							</div>
							<h3>选择编入的行政班</h3>
							<hr/>
						</div>
						
						<cfif rs_class.recordCount>
								
								<cfset row = 0 />
								<table class="UIEditable">
									<thead>
										<tr>
											<td width="18"></td>
											<td>班级</td>
											<td width="80">所在校区</td>
											<td width="60" align="center">计划人数</td>
											<td width="40" align="center">学生数</td>
											<td width="18"></td>
										</tr>
									</thead>
									<tbody>
                                        <cfloop query="rs_class" >
											<cfset structInsert(passArgs, "CLSID", rs_class.cls_id, true) />
											<cfset row++ />
											<tr class="editRows <cfif rs_class.cls_size lt rs_class.cls_scale>noticeRow1</cfif>">
												<td class="index"><cfoutput>#row#</cfoutput></td>
												<td><cfoutput>#rs_class.cls_name#</cfoutput></td>
												<td><cfoutput>#rs_class.campus_name#</cfoutput></td>
												<td align="center"><span class="numeric"><cfoutput>#rs_class.cls_size#</cfoutput></span></td>
												<td align="center"><span class="numeric"><cfoutput>#rs_class.cls_scale#</cfoutput></span></td>
												<td><a title="编入该班级" class="stat examer" href="<cfoutput>#buildURL('statusChangeWizardCreateProfile', passArgs)#</cfoutput>"></a></td>
											</tr>
										</cfloop>
										<!--- 移出班级号参数 --->
										<cfset structDelete( passArgs, "CLSID", false ) />
									</tbody>
								</table>
								
							<cfelse>
								
								<div class="systemNotice">
									<p>该专业在指定年级没有招生</p>
								</div>
								
						</cfif>
						
					</div>
					
				</cfif>
				
			</div>
		</li>
	</ul>
</div>
				
				


